package com.wawayaya.base;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.wawayaya.AppContext;
import com.wawayaya.interf.BaseFragmentInterf;
import com.wawayaya.util.event.ShelfEvent;

import butterknife.ButterKnife;
import de.greenrobot.event.EventBus;

/**
 * Fragment 基类
 * 
 */
public abstract class BaseFragment extends Fragment implements
        View.OnClickListener, BaseFragmentInterf {

    protected LayoutInflater mInflater;
    protected Context    context;


    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        this.context = context;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EventBus.getDefault().register(this);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        this.mInflater = inflater;
        View view = super.onCreateView(inflater, container, savedInstanceState);
        return view;
    }

    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    public void onPause() {
        super.onPause();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }


    @Override
    public void initView(View view) {

    }

    @Override
    public void initData() {

    }

    @Override
    public void onClick(View v) {

    }

    public abstract void onEvent(ShelfEvent eventData);
    /**
     * 清空数据
     */
    public abstract void clear();
}
